package com.campus.payment.feign;

import com.campus.common.bean.common.Resp;
import com.campus.payment.dto.ProfitSharingRequestDTO;
import com.campus.payment.dto.ProfitSharingResponseDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 分账服务Feign客户端
 *
 * @author ZhaoYuJie
 * @since 2025-01-15
 */
@FeignClient(name = "campus-payment", contextId = "profit-sharing-client", url = "${feign.campus-payment.url:http://localhost:8085}", path = "/profit-sharing")
public interface ProfitSharingFeignClient {

    /**
     * 添加分账接收方
     *
     * @param type 接收方类型：MERCHANT_ID-商户号，PERSONAL_OPENID-个人OpenID
     * @param account 接收方账号
     * @param name 接收方名称
     * @param relationshipType 与分账方的关系类型
     * @return 是否添加成功
     */
    @PostMapping("/add-receiver")
    Resp<Boolean> addReceiver(@RequestParam("type") String type,
                               @RequestParam("account") String account,
                               @RequestParam(value = "name",required = false) String name,
                               @RequestParam("relationshipType") String relationshipType);

    /**
     * 请求分账
     *
     * @param request 分账请求
     * @return 分账响应
     */
    @PostMapping("/create")
    Resp<ProfitSharingResponseDTO> createProfitSharing(@RequestBody ProfitSharingRequestDTO request);

    /**
     * 查询分账结果
     *
     * @param subMchid 子商户号
     * @param transactionId 微信支付订单号
     * @param outOrderNo 商户分账单号
     * @return 分账响应
     */
    @GetMapping("/query")
    Resp<ProfitSharingResponseDTO> queryProfitSharing(@RequestParam("subMchid") String subMchid,
                                                       @RequestParam("transactionId") String transactionId,
                                                       @RequestParam("outOrderNo") String outOrderNo);
}